﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Classes;
using VAdvantage.Grids;


namespace VAdvantage.Controls
{
    public class VTextBlock:IControl
    {
        private TextBlock txtBlock = new TextBlock();

        private GridField _field = null;

        private string _colName = "";

        public VTextBlock()
        {
            txtBlock.TextWrapping = TextWrapping.Wrap;

            this.txtBlock.Style = App.Current.Resources["MsgBlockStyle"] as Style;
            //this.txtBlock.for
            //txtBlock.Style =    VTextBlockStyle
        }

        public VTextBlock(string colname):this()
        {
            this._colName = colname;
        }


        #region IControl Members

        public event EventHandler VetoableChangeListener;

        public int GetDisplayType()
        {
            return DisplayType.Label;
        }

        public void SetDisplayType(int displayType)
        {
            
        }

        public bool GetIsReadonly()
        {
            return true;
        }

        public void SetReadOnly(bool readOnly)
        {
            //throw new NotImplementedException();
        }

        public Grids.GridField GetField()
        {
            return _field;
        }

        public void SetField(Grids.GridField mField)
        {
            _field = mField;
            txtBlock.Text = _field.GetHelp();
        }

        public string GetName()
        {
            return _colName;
        }

        public void SetName(string name)
        {
            this._colName = name;
        }

        public string GetText()
        {
            return "";
        }

        public object GetValue()
        {
            return null;
        }

        public void SetValue(object value)
        {
            //throw new NotImplementedException();
        }

        public bool GetIsMandatory()
        {
            return false;
        }

        public void SetIsMandatory(bool value)
        {
            //throw new NotImplementedException();
        }

        public void SetBackGround(bool value)
        {
            //throw new NotImplementedException();
        }

        public string GetSelectedText()
        {
            return "";
        }

        public bool IsDisabled()
        {
            return true;
        }

        public void SetDisabled(bool disabled)
        {
            
        }

        public int GetTabIndex()
        {
            return -1;
        }

        public void SetTabindex(int tabindex)
        {
            
        }

        public bool Multiline
        {
            get
            {
                return true;
            }
            set
            {
                
               // this.Multiline = true;
            }
        }

        public bool Visible
        {
            get
            {
                return txtBlock.Visibility == Visibility.Visible;
            }
            set
            {
                txtBlock.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
            }
        }

        public bool Focused
        {
            get
            {
                return false;
            }
        }

        public string BindValue
        {
           set 
           { 
            
           }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            txtBlock = null;
        }

        #endregion

        internal FrameworkElement GetLabel()
        {
            return txtBlock;
        }
    }
}
